## [1] "Run Completed at 2018-03-03 06:48:00"

Absence data

Models

Random Baseline

## sink("models/SpeciesIdentity.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##     #observation
##     logit(s[x])<-alpha[Bird[x],Plant[x]]
##     Yobs[x] ~ dbern(s[x])
##     
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       logit(snew[x])<-alpha[NewBird[x],NewPlant[x]]
##       Ynew_pred[x]~dbern(snew[x])
##     
##       #Assess fit, proportion of corrected predicted observations
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
## 
##     }
##     
##     #Priors
## 
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
## 
##         #Intercept
##         #logit prior, then transform for plotting
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
## 
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 0
##    Unobserved stochastic nodes: 50408
##    Total graph size: 206884
## 
## Initializing model

Assess Convergence

Species Identity

## sink("models/SpeciesIdentity.jags")
## cat("
##     model {
##     
##     for (x in 1:Nobs){
## 
##     #observation
##     logit(s[x])<-alpha[Bird[x],Plant[x]]
##     Yobs[x] ~ dbern(s[x])
##     
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       logit(snew[x])<-alpha[NewBird[x],NewPlant[x]]
##       Ynew_pred[x]~dbern(snew[x])
##     
##       #Assess fit, proportion of corrected predicted observations
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
## 
##     }
##     
##     #Priors
## 
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
## 
##         #Intercept
##         #logit prior, then transform for plotting
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
## 
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 19724
##    Total graph size: 206884
## 
## Initializing model

Assess Convergence

Detectability + Species Identity

## sink("models/SpeciesIdentity_Detect.jags")
## cat("
##     model {
##     
##     #True interaction probability for each bird, plant
##     for (i in 1:Birds){
##       for(j in 1:Plants){
##       for(k in 1:Cameras){
##           logit(s[i,j,k])<-alpha[i,j]
##           z[i,j,k] ~ dbern(s[i,j,k])
##           }
##         }
##       }
## 
##     #Observation Model
##     for (x in 1:Nobs){
##       
##       #Detection Process
##       p[x]<-detect[Bird[x]] * z[Bird[x],Plant[x],Camera[x]]
## 
##       #Observation
##       Yobs[x] ~ dbern(p[x])
##     }
##     
##     #Assess Model Fit - Predict remaining data
## 
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       pnew[x] <- detect[NewBird[x]] * z[NewBird[x],NewPlant[x],NewCamera[x]]
## 
##       #Predicted observation
##       Ynew_pred[x]~dbern(pnew[x])
##       
##       #Assess fit, proportion of corrected predicted links
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##       logit(detect[x])<-dcam[x]
##       dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     #Species level priors
##     for (i in 1:Birds){
##       for (j in 1:Plants){
##         #Logit Intercept
##         alpha[i,j] ~ dnorm(0,0.386)
##       } 
##     }
##     
##     #OBSERVATION PRIOR
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive error
##     fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 575906
##    Total graph size: 825256
## 
## Initializing model

Assess Convergence

# Species Identity + Detection + Elevation

## sink("models/SpeciesIdentity_Detect_Elevation.jags")
## cat("
##     model {
##     
##     #Ecological Process Model
##     #True State for each bird, plant, camera
##     for (i in 1:Birds){
##       for(j in 1:Plants){
##         for(k in 1:Cameras){
##           
##           #Occurrence 
##           logit(psi[i,j,k])<-alpha_occ[i] + beta_occ[i] * elevation[k]
##           occ[i,j,k] ~ dbern(psi[i,j,k])
## 
##           #Interaction
##           logit(s[i,j,k])<-alpha[i,j]
## 
##           #Conditional probability of interaction|occurrence
##           rho[i,j,k] <- s[i,j,k] * occ[i,j,k]
## 
##           z[i,j,k] ~ dbern(rho[i,j,k])
##         }
##       }
##     }
##     
##     #Observation Model
##     for (x in 1:Nobs){
##     
##     #Observation, conditional on detection and occurrence.
##     p[x]<-detect[Bird[x]] * z[Bird[x],Plant[x],Camera[x]]
##     Yobs[x] ~ dbern(p[x])
## 
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       pnew[x]<-detect[NewBird[x]] * z[NewBird[x],NewPlant[x],NewCamera[x]]
##       
##       #Predicted observation
##       Ynew_pred[x]~dbern(pnew[x])
##       
##       #Assess fit, proportion of corrected predicted links
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
## 
##     #Occurrence model
##     for(x in 1:Birds){
##       alpha_occ[x] ~ dnorm(0,0.386)
##       beta_occ[x] ~ dnorm(0,0.386)
##       beta_season[x] ~ dnorm(0,0.386)
##       beta_int[x] ~ dnorm(0,0.386)
##     }
## 
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##       logit(detect[x])<-dcam[x]
##       dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     for (i in 1:Birds){
##     for (j in 1:Plants){
##       #Intercept
##       #logit prior, then transform for plotting
##       alpha[i,j] ~ dnorm(0,0.386)
##     }
##     }
##     
##     #Observation group prior
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive check
##     fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 1132146
##    Total graph size: 1955988
## 
## Initializing model
## 
##     user   system  elapsed 
## 7182.411   24.561 7562.584

Assess Convergence

Predicted elevation ranges

Model Comparison

By Species

Detectability

Proportion of predicted observations

Predicted network statistics

Dashed line is the observed network from the time-series.

Predicted betadiversity

Split data into wet (November - May) versus dry season (June - October)

Rewiring: Change in the probability of species interaction

## sink("models/SpeciesIdentity_Detect_Elevation_Beta.jags")
## cat("
##     model {
##     
##     #Ecological Process Model
##     #True State for each bird, plant, camera
##     for (i in 1:Birds){
##     for(j in 1:Plants){
##     for(k in 1:Cameras){
##     
##         #Occurrence 
##         logit(psi[i,j,k])<-alpha_occ[i] + beta_occ[i] * elevation[k]
##         occ[i,j,k] ~ dbern(psi[i,j,k])
##         
##         #Interaction
##         logit(s[i,j,k])<-alpha[i,j] + beta_season[i,j] *Season[k]
##         
##         #Conditional probability of interaction|occurrence
##         rho[i,j,k] <- s[i,j,k] * occ[i,j,k]
##         z[i,j,k] ~ dbern(rho[i,j,k])
## 
##     }
##     }
##     }
##     
##     #Observation Model
##     for (x in 1:Nobs){
##     
##       #Observation, conditional on detection and occurrence.
##       p[x]<-detect[Bird[x]] * z[Bird[x],Plant[x],Camera[x]]
##       Yobs[x] ~ dbern(p[x])
##   
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     
##     for(x in 1:Nnewdata){
##     
##       #Generate prediction
##       pnew[x]<-detect[NewBird[x]] * z[NewBird[x],NewPlant[x],NewCamera[x]]
##       
##       #Predicted observation
##       Ynew_pred[x]~dbern(pnew[x])
##       
##       #Assess fit, proportion of corrected predicted links
##       Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##       
##     }
##     
##     #Priors
##     
##     #Occurrence model
##     for(x in 1:Birds){
##       alpha_occ[x] ~ dnorm(0,0.386)
##       beta_occ[x] ~ dnorm(0,0.386)
##     }
##     
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##       logit(detect[x])<-dcam[x]
##       dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     for (i in 1:Birds){
##     for (j in 1:Plants){
##         #Interaction probability
##         alpha[i,j] ~ dnorm(0,0.386)
##         #Effect of season
##         beta_season[i,j] ~ dnorm(0,0.386)
##     }
##     }
##     
##     #Observation group prior
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive check
##     #fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 1132986
##    Total graph size: 1961859
## 
## Initializing model
## 
##     user   system  elapsed 
## 7506.279   37.927 7557.858

Assess Convergence

Effect of season on interaction probabilities

Dissimilairty in interactions (Beta_WN from Poisot 2012) Dashed line is the observed network from the time-series.

Note that this is really a measure of dissimilairty in one level (hummimngbirds), as the dissimilarity in plants is fixed by the sampling protocol. While there be a correlation between the species pool and the chosen plant to film, this is filtered by a human placing a camera at that plant, and as such isn’t a true measure of plant dissimiality.

Turnover: Change in the probability of species occurrence

## sink("models/SpeciesIdentity_Detect_Elevation_SeasonOcc.jags")
## cat("
##     model {
##     
##     #Ecological Process Model
##     #True State for each bird, plant, camera
##     for (i in 1:Birds){
##     for(j in 1:Plants){
##     for(k in 1:Cameras){
##     
##     #Occurrence 
##     logit(psi[i,j,k])<-alpha_occ[i] + beta_occ[i] * elevation[k] + beta_season[i] *Season[k] + beta_int[i] *Season[k] * elevation[k]
##     occ[i,j,k] ~ dbern(psi[i,j,k])
##     
##     #Interaction
##     logit(s[i,j,k])<-alpha[i,j] 
##     
##     #Conditional probability of interaction|occurrence
##     rho[i,j,k] <- s[i,j,k] * occ[i,j,k]
##     z[i,j,k] ~ dbern(rho[i,j,k])
##     
##     }
##     }
##     }
##     
##     #Observation Model
##     for (x in 1:Nobs){
##     
##     #Observation, conditional on detection and occurrence.
##     p[x]<-detect[Bird[x]] * z[Bird[x],Plant[x],Camera[x]]
##     Yobs[x] ~ dbern(p[x])
##     
##     }
##     
##     #Assess Model Fit - Predict remaining data
##     
##     for(x in 1:Nnewdata){
##     
##     #Generate prediction
##     pnew[x]<-detect[NewBird[x]] * z[NewBird[x],NewPlant[x],NewCamera[x]]
##     
##     #Predicted observation
##     Ynew_pred[x]~dbern(pnew[x])
##     
##     #Assess fit, proportion of corrected predicted links
##     Enew[x]<-abs(Ynew[x]-Ynew_pred[x])
##     
##     }
##     
##     #Priors
##     
##     #Occurrence model
##     for(x in 1:Birds){
##     alpha_occ[x] ~ dnorm(0,0.386)
##     beta_occ[x] ~ dnorm(0,0.386)
##     beta_season[x] ~ dnorm(0,0.386)
##     beta_int[x] ~ dnorm(0,0.386)
##     }
##     
##     #Observation model
##     #Detect priors, logit transformed - Following lunn 2012 p85
##     for(x in 1:Birds){
##     logit(detect[x])<-dcam[x]
##     dcam[x]~dnorm(omega_mu,omega_tau)
##     }
##     
##     #Process Model
##     for (i in 1:Birds){
##     for (j in 1:Plants){
##     #Interaction probability
##     alpha[i,j] ~ dnorm(0,0.386)
##     #Effect of season
##     }
##     }
##     
##     #Observation group prior
##     omega_mu ~ dnorm(0,0.386)
##     omega_tau ~ dunif(0,10)
##     
##     #derived posterior predictive check
##     #fitnew<-sum(Enew[])
##     
##     }
##     ",fill=TRUE)
## 
## sink()
## Compiling model graph
##    Resolving undeclared variables
##    Allocating nodes
## Graph information:
##    Observed stochastic nodes: 30684
##    Unobserved stochastic nodes: 1132146
##    Total graph size: 1966339
## 
## Initializing model
## 
##     user   system  elapsed 
## 7448.018   47.428 7550.844

Assess Convergence

Predicted elevation ranges

Effect of season on occurrence probabilities

Dissimilairty in interactions (Beta_WN from Poisot 2012) Dashed line is the observed network from the time-series.

Note that this is really a measure of dissimilairty in one level (hummimngbirds), as the dissimilarity in plants is fixed by the sampling protocol. While there be a correlation between the species pool and the chosen plant to film, this is filtered by a human placing a camera at that plant, and as such isn’t a true measure of plant dissimiality.

Sample interaction

Model overlap

Create a kind of venn diagram on PCA of model similarity based on per link discrepency.

## # A tibble: 16 x 3
## # Groups:   Model [4]
##    Model                      mean pair                                   
##    <chr>                     <dbl> <chr>                                  
##  1 Species_Detect_Elevation -0.932 Booted Racket-tail_Stromanthe stromant…
##  2 Species                  -0.917 Booted Racket-tail_Stromanthe stromant…
##  3 Species_Detect           -0.912 Brown Inca_Psammisia aberrans          
##  4 Species_Detect_Elevation -0.910 Brown Inca_Psammisia aberrans          
##  5 Species_Detect           -0.896 Booted Racket-tail_Stromanthe stromant…
##  6 Species_Detect_Elevation -0.885 Violet-tailed Sylph_Begonia longirostr…
##  7 Species                  -0.872 Brown Inca_Psammisia aberrans          
##  8 Species_Detect           -0.868 Violet-tailed Sylph_Begonia longirostr…
##  9 Species_Detect           -0.854 Violet-tailed Sylph_Drymonia tenuis    
## 10 Species_Detect_Elevation -0.845 Violet-tailed Sylph_Kohleria affinis   
## 11 Species                  -0.829 Violet-tailed Sylph_Kohleria affinis   
## 12 Species                  -0.810 Violet-tailed Sylph_Drymonia tenuis    
## 13 Random                   -0.531 Fawn-breasted Brilliant_Columnea cilia…
## 14 Random                   -0.530 Wedge-billed Hummingbird_Drymonia tenu…
## 15 Random                   -0.528 Gorgeted Sunangel_Gasteranthus lateral…
## 16 Random                   -0.525 Booted Racket-tail_Palicourea demissa

Without random model